package com.example.im.common

import android.os.Environment
import com.example.im.db.DatabaseStorage
import org.jivesoftware.smack.packet.Message
import org.jivesoftware.smack.roster.packet.RosterPacket

object Constants {
    //内网
    const val HTTP_URL_INTRA_NET = "http://192.168.8.5:8888/api/"

    //    const val SERVICE_IP = "47.56.228.33"

    const val SERVICE_IP = "101.37.253.11"

    const val HTTP_URL_UPDATE_FILE =
        "http://${SERVICE_IP}:8090/services/baseservice/api/images/upload"

    const val HTTP_URL_INVITE_CODE_SET =
        "http://${SERVICE_IP}:8090/services/baseservice/api/invite/generator"

    const val HTTP_URL_INVITE_CODE_GET =
        "http://${SERVICE_IP}:8090/services/baseservice/api/invite/get-invite"


    const val XMPP_SERVICE_DOMAIN = "openfire-voc"
    const val XMPP_SERVICE_HOST = SERVICE_IP
    const val XMPP_SERVICE_PORT = 5222
    const val XMPP_SERVICE_RESOURCE = "PHONE"
    const val XMPP_SERVICE_ROOM = "conference.$XMPP_SERVICE_DOMAIN"

    val ROOM_NICKNAME: String
        get() = "${DatabaseStorage.getAccountInfoStorage().name}(${DatabaseStorage.getAccountInfoStorage().username})"


    /**
     * 用户类型
     * */
    const val USER_ROOM_1 = 1//好友
    const val USER_ROOM_2 = 2//聊天室

    /**
     * 用户订阅关系
     * */
    val USER_ROOM_SUB_0 = RosterPacket.ItemType.none.ordinal
    val USER_ROOM_SUB_1 = RosterPacket.ItemType.to.ordinal
    val USER_ROOM_SUB_2 = RosterPacket.ItemType.from.ordinal
    val USER_ROOM_SUB_3 = RosterPacket.ItemType.both.ordinal
    val USER_ROOM_SUB_4 = RosterPacket.ItemType.remove.ordinal

    /**
     * 聊天信息
     * */
    const val CHAT_ACTION_1 = 1//发送
    const val CHAT_ACTION_2 = 2//接收
    const val CHAT_ACTION_3 = 3//其他

    /**
     * 聊天种类
     * */
    val CHAT_KIND_1 = Message.Type.chat.ordinal//单聊
    val CHAT_KIND_2 = Message.Type.groupchat.ordinal//群聊

    /**
     * 聊天消息类型
     * */
    const val CHAT_TYPE_CHANGE = -2//修改群昵称
    const val CHAT_TYPE_TIME = -1//时间
    const val CHAT_TYPE_OTHER = 0//其他
    const val CHAT_TYPE_TEXT = 1//文本
    const val CHAT_TYPE_VOICE = 2//语音
    const val CHAT_TYPE_PHOTO = 3//图片
    const val CHAT_TYPE_VIDEO = 4//视频
    const val CHAT_TYPE_FILE = 5//文件

    /**
     * 聊天消息状态
     * */
    const val CHAT_STATUS_0 = 0//消息已读
    const val CHAT_STATUS_1 = 1//消息未读
    const val CHAT_STATUS_2 = 2//消息发送中
    const val CHAT_STATUS_3 = 3//消息发送失败


    const val BUNDLE_T0_CHAT_DATA = "BUNDLE_T0_CHAT_DATA"
    const val BUNDLE_T0_USER_ROOM_DATA = "BUNDLE_T0_USER_DATA"//向用户信息传递数据
    const val BUNDLE_T0_USER_ROOM_POINT = "BUNDLE_T0_USER_POINT"//向用户信息传递数据
    const val BUNDLE_T0_SEARCH_DATA = "BUNDLE_T0_SEARCH_DATA"
    const val BUNDLE_VIDEO_PATH = "BUNDLE_VIDEO_PATH"

    /**
     * 用户信息界面传递数据key
     * */
    const val BUNDLE_T0_USER_POINT_1 = 1//指向用户信息页面
    const val BUNDLE_T0_USER_POINT_2 = 2//指向搜索用户页面
    const val BUNDLE_T0_USER_POINT_3 = 3//指向添加用户页面

    /**
     * 聊天室信息界面传递数据key
     * */
    const val BUNDLE_T0_ROOM_POINT_1 = 1//指向聊天室信息页面
    const val BUNDLE_T0_ROOM_POINT_2 = 2//指向创建聊天室页面
    const val BUNDLE_T0_ROOM_POINT_3 = 3//指向邀请好朋友页面
    const val BUNDLE_T0_ROOM_POINT_4 = 4//指向聊天室人员页面


    const val ACCOUNT_ATTRIBUTES = "ACCOUNT_ATTRIBUTES"
    const val ACCOUNT_USER_NAME = "ACCOUNT_USER_NAME"
    const val ACCOUNT_NICK_NAME = "ACCOUNT_NICK_NAME"
    const val ACCOUNT_PASSWORDS = "ACCOUNT_PASSWORDS"
    const val ACCOUNT_SERVER_IP = "ACCOUNT_SERVER_IP"

    val EXTERNAL_STORAGE_DIRECTORY = "${Environment.getExternalStorageDirectory()}/im"

}
